package com.sunrise.gateway.web.core;

import com.dap.param.GeneratePlatformCtrlDataInterface;
import com.dap.param.StringInput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/***
 * 参数通过get请求的参数过来的回调, 没有权限信息
 * @author wangmin
 */
@Service
public class ParamMapGetRequestEngine extends EngineBase {
    @Autowired
    private GeneratePlatformCtrlDataInterface generatePlatformCtrlDataInterface;

    public String execute(HttpServletRequest req, String leaveOutGroupNamePrefix, String internalRequestSource) {
        String group = getGroupName(req, leaveOutGroupNamePrefix);

        Map<String, Object> paramMap = req.getParameterMap();
        if (paramMap.isEmpty()) {
            return null;
        }

        StringInput stringInput = new StringInput(generatePlatformCtrlDataInterface.generate(internalRequestSource), paramMap);
        return executeRequestStr(group, stringInput, true);
    }

}
